import { LoginForm, LoginResult, VerifyCode } from '@/api/auth/types';
import http from "@/utils/request";
import { AxiosPromise } from 'axios';


export function loginApi(data: LoginForm): AxiosPromise<LoginResult> {
  return http({
    url: '/youlai-auth/oauth/token',
    method: 'post',
    params: data,
    headers: {
      Authorization: 'Basic bWFsbC1hZG1pbjoxMjM0NTY=', // 客户端信息Base64明文：mall-admin:123456
    },
  });
}



export function getCaptcha(): AxiosPromise<VerifyCode> {
  return http({
    url: '/captcha?t=' + new Date().getTime().toString(),
    method: 'get',
  });
}

//当前登录人信息
export const Person = () => {
  return http.get("/prod-api/api/v1/users/me")
}


let token = localStorage.getItem("token")
// 获取路由列表
export const Permmenu = () => {
  return http.request({
    url: "/youlai-system/api/v1/menus/routes",
    method: "get",
    headers: {
      Authorization: localStorage.getItem("token")
    }
  })
}

// export const Permmenu = (params: { keywords?: string, status: string }) => {
//   return ({
//     URL: "/api/v1/menus",
//     method: 'get',
//     params: {
//       keywords,
//       status
//     }
//   })
// }



export const GetUserList = () => {
  return http.request({
    url: "/youlai-system/api/v1/users/me",
    method: "get",
    headers: {
      Authorization: localStorage.getItem("token")
    }
  })
}

//获取角色列表
// /api/admin/base/sys/role/page
export const getRoleList = () => {
  return http.get("/api/v1/roles/page")
}

//获取菜单列表
// /api/admin/base/sys/menu/list
export const getMenuList = () => {
  return http.get("/api/v1/menus")
}


//参数列表
// /api/admin/base/sys/param/page
// export const getConfigList = () => {
//   return http.post("/api/admin/base/sys/param/page")
// }